<?php
namespace app\admin\controller;

\think\Loader::import('controller/Controller', \think\Config::get('traits_path') , EXT);

use app\admin\Controller;

class Foot extends Controller
{
    use \app\admin\traits\controller\Controller;
    // 方法黑名单
    protected static $blacklist = [];

    /**
     * 首页
     * @return mixed
     */
    public function index()
    {
        $model = $this->getModel();

        // 列表过滤器，生成查询Map对象
        $map = $this->search($model, [$this->fieldIsDelete => $this::$isdelete]);

        // 特殊过滤器，后缀是方法名的
        $map['_paginate'] = false;

        // 自定义过滤器
        if (method_exists($this, 'filter')) {
            $this->filter($map);
        }

        $lists = $this->datalist($model, $map, null, 'sort desc,id', true, true);
        $tree = new \Tree(['flat'=>true, 'pad_name'=>'name']);
        $lists = $tree->getTree($lists);
        // 模板赋值显示
        $this->view->assign('list', $lists);
        $this->view->assign("count", count($lists));
        $this->view->assign("page", '');
        $this->view->assign('numPerPage', 0);

        return $this->view->fetch();
    }

    protected function filter(&$map)
    {
        if ($this->request->param("name")) {
            $map['name'] = ["like", "%" . $this->request->param("name") . "%"];
        }
    }
}